var t = require;
var e = module;
var o = exports;
var a,
    i =
        (this && this.__extends) ||
        ((a = function (t, e) {
            return (a =
                Object.setPrototypeOf ||
                ({__proto__: []} instanceof Array &&
                    function (t, e) {
                        t.__proto__ = e;
                    }) ||
                function (t, e) {
                    for (var o in e) Object.prototype.hasOwnProperty.call(e, o) && (t[o] = e[o]);
                })(t, e);
        }),
        function (t, e) {
            a(t, e);
            function o() {
                this.constructor = t;
            }
            t.prototype = null === e ? Object.create(e) : ((o.prototype = e.prototype), new o());
        }),
    n =
        (this && this.__decorate) ||
        function (t, e, o, a) {
            var i,
                n = arguments.length,
                r = n < 3 ? e : null === a ? (a = Object.getOwnPropertyDescriptor(e, o)) : a;
            if ("object" == typeof Reflect && "function" == typeof Reflect.decorate) r = Reflect.decorate(t, e, o, a);
            else
                for (var s = t.length - 1; s >= 0; s--)
                    (i = t[s]) && (r = (n < 3 ? i(r) : n > 3 ? i(e, o, r) : i(e, o)) || r);
            return n > 3 && r && Object.defineProperty(e, o, r), r;
        };
Object.defineProperty(o, "__esModule", {value: !0});
var r = t("BoxItem"),
    s = cc._decorator,
    c = s.ccclass,
    p =
        (s.property,
        s.menu,
        (function (t) {
            i(e, t);
            function e() {
                var e = (null !== t && t.apply(this, arguments)) || this;
                e.recList = [];
                e.tag = "InvateItem";
                e.equipData = null;
                return e;
            }
            e.prototype.setData = function (t, e) {
                this.updateView(t, e);
            };
            e.prototype.getSkinData = function (t) {
                var e = {};
                e.front = ParseTool.getFront(t);
                e.back = ParseTool.getBack(t);
                return e;
            };
            e.prototype.updateView = function (t, e) {
                this.recAll();
                this.equipData = {id: t, nameId: e};
                var o = CacheDataManager.getEmployee(),
                    a = this.getSkinData(o[3e3]);
                this.setFrontView(a);
                for (
                    var i = CacheDataManager.getCostumeup(),
                        n = CacheDataManager.getCostume(),
                        r = CacheDataManager.getIcon(),
                        s = [],
                        c = {},
                        p = 0;
                    p < t.length;
                    p++
                ) {
                    var l = t[p],
                        d = l.data,
                        u = n[i[d].costume_id],
                        h = r[CacheDataManager.getEquipFrontIcon(d)].icon_name,
                        f = u.postion_x || 0,
                        y = u.postion_y || 0,
                        v = u.postion_r || 0;
                    c[p + 1] = {x: f, y: y, r: v};
                    s.push(h);
                    this.addBoxItem(d, l.lv);
                }
                var g = this._catAnimal.$CatViewSprite;
                g.setFrontEquit(s[0], s[1], s[2]);
                this._nameLab1.$Label.string = CacheDataManager.getLang(e);
                g.setHatPos(c);
                this._catAnimal.$CatAnimal.playWait();
            };
            e.prototype.setFrontView = function (t) {
                var e = this._catAnimal.$CatViewSprite;
                if (e && t && t.front) {
                    var o = t.front;
                    e.setFrontSkin(o.Body_Front, o.Eyes, o.Face, o.Hand, o.Tail);
                }
            };
            e.prototype.addBoxItem = function (t, e) {
                var o = this;
                if (t) {
                    var a = QLooperNode.getNode(QLooperNode.tag_boxItem);
                    if (a) {
                        a.parent = this._boxParent;
                        a.setPosition(cc.Vec2.ZERO);
                        this.recList.push(a);
                        var i = a.getComponent(r.default);
                        if (i) {
                            var n = CacheDataManager.getCostumeup()[t],
                                s = CacheDataManager.getCostume()[n.costume_id];
                            i.tag = this.tag;
                            i.id = t;
                            i.nodeKindItem.setTypeKind(s.type, n.quality);
                            i.typeIndex = e;
                            i.levelLab.string = "lv:" + e;
                            i.resetView();
                            SpriteView.setTaskSprite(i.iconSprite, CacheDataManager.getEquipBaseIcon(t));
                            i.setQualityData(n.quality);
                        }
                    } else
                        this.scheduleOnce(function () {
                            o.addBoxItem(t, e);
                        }, 0.1);
                }
            };
            e.prototype.recAll = function () {
                for (var t = 0; t < this.recList.length; t++) QLooperNode.putNode(this.recList[t]);
                this.recList.length = 0;
            };
            e.prototype._onInvateBtnTouchEnd = function () {
                EVUIEffView.emit(EVUIEffView.clickInvate, this.equipData);
            };
            return n([c], e);
        })(Thor));
o.default = p;
